package sc;

import javax.annotation.processing.SupportedSourceVersion;
import java.util.ArrayList;
import java.util.Scanner;

/**
 * @Author admin
 * @Date 2019/3/29 10:31
 */
public class Test3 {
    static Scanner sc=new Scanner(System.in);
    static UserDaoimp userDaoimp=new UserDaoimp();
    public static void main(String[] args) {
        System.out.println("-----欢迎光临-----");
        while (true){
            System.out.println("1.注册");
            System.out.println("2.登陆");
            System.out.println("3.退出");
            System.out.println("请输入你的选择：");
            int xz=sc.nextInt();
            while (true){
                if (xz==1){
                    UI1();
                    break;
                }else if (xz==2){
                    UI2();
                    break;
                }else if (xz==3){
                    System.out.println("-----退出-----");
                    System.exit(0);
                }else {
                    System.out.println("输入有误");
                    break;
                }
            }

        }
    }

    public static void UI1(){
        Scanner sc=new Scanner(System.in);
        System.out.println("-----注册界面-----");
        System.out.println("请输入用户名");
        String name=sc.nextLine();
        System.out.println("请输入密码");
        String password =sc.nextLine();
        Uesr uesr=new Uesr(name,password);
        userDaoimp.register(uesr);
    }
    public static void UI2(){
        Scanner sc=new Scanner(System.in);
        System.out.println("-----登陆界面-----");
        System.out.println("请输入用户名");
        String name=sc.nextLine();
        System.out.println("请输入密码");
        String password =sc.nextLine();
        boolean result=userDaoimp.login(name,password);
        if (result){
            System.out.println("登陆成功");
        }else {
            System.out.println("登录失败");
        }
    }

}
